package com.gs.thunder.service.impl;

import com.gs.thunder.dao.UserDao;
import com.gs.thunder.entity.Resource;
import com.gs.thunder.entity.Role;
import com.gs.thunder.entity.User;
import com.gs.thunder.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private UserDao userDao;


   public void addUser(User user){
        userDao.addUser(user);
    }

    public User getUserById(String id) {
        return userDao.queryUserById(id);
    }


    public List<Resource> getResourcesByUserId(String id) {
        return userDao.queryResourcesByUserId(id);
    }

    public void addUserRole(String userId, int roleId) {
        userDao.addUserRole(userId, roleId);
    }


    public List<User> getAllUser() {
        return userDao.queryAllUser();
    }


    public List<Role> getRolesByUserId(String userId) {
        return userDao.queryRolesByUserId(userId);
    }

    public void deleteUser(String id) {
        userDao.deleteUser(id);
    }

    public void deleteUserRoleByUserId(String userId) {
        userDao.deleteUserRoleByUserId(userId);
    }
}
